package com.andon.lcz.h264rtmp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.andon.lcz.h264rtmp.pusher.LivePusher;
import com.tencent.bugly.crashreport.CrashReport;

public class MainActivity extends AppCompatActivity {

    private static final String PUSH_URL = "rtmp://47.94.195.223/myapp/mystream";
//    private static final String PUSH_URL = "rtmp://send3.douyu.com/live/3522434rprFQ2PGT?wsSecret=f2e9646c817a77ea25566c1bbef3a49c&wsTime=59e837b6&wsSeek=off";

    private SurfaceView previewView;

    private LivePusher livePusher;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CrashReport.initCrashReport(getApplicationContext(), "996f233725", false);
        setContentView(R.layout.activity_main);
        previewView = (SurfaceView) findViewById(R.id.preview_view);
        livePusher = new LivePusher(this, previewView.getHolder());
    }

    public void startLive(View view) {
        Button startBtn = (Button) view;
        if (startBtn.getText().equals("开始直播")) {
            livePusher.start(PUSH_URL);
            startBtn.setText("停止直播");
        } else {
            livePusher.stop();
            startBtn.setText("开始直播");
        }
    }

    public void switchCamera(View v) {
        livePusher.switchCamera();
    }
}
